package com.young4j.xinsuiwutuobang.service;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.young4j.xinsuiwutuobang.model.Customer;
import com.young4j.xinsuiwutuobang.util.DataBaseUtils;
import com.young4j.xinsuiwutuobang.util.PropsUtils;

public class CustomerService {
	private static final Logger LOGGER = LoggerFactory.getLogger(CustomerService.class);
	/**
	 * 获取客户列表
	 * @return
	 */
	public List<Customer> getCustomerList(){
		try {
			List<Customer> customerList = new ArrayList<Customer>();
			String sql = "SELECT * FROM customer";
			customerList = DataBaseUtils.queryEntityList(Customer.class, sql, null);
			return customerList;
		} catch (Exception e) {
			LOGGER.error("execuse sql failure",e);
		}
		return null;
	}
	/**
	 * 创建客户
	 * @param fieldMap
	 * @return
	 */
	public boolean createCustomer(Map<String,Object> fieldMap){
		return DataBaseUtils.insertEntity(Customer.class, fieldMap);
	}
	/**
	 * 更新实体
	 * @param id
	 * @param fieldMap
	 * @return
	 */
	public boolean updateCustomer(long id,Map<String,Object> fieldMap){
		return DataBaseUtils.updateEntity(Customer.class, id, fieldMap);
	}
	/**
	 * 删除实体
	 * @param id
	 * @return
	 */
	public boolean deleteCustomer(long id){
		return DataBaseUtils.deleteEntity(Customer.class, id);
	}
}
